//
//  QGHelpDetailViewController.m
//  QuanGou
//
//  Created by qqqq on 15/11/19.
//  Copyright © 2015年 DongYongFei. All rights reserved.
//

#import "QGHelpDetailViewController.h"
#import <UIImageView+WebCache.h>

@interface QGHelpDetailViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *userPictureImageView;
@property (weak, nonatomic) IBOutlet UILabel *userNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *userSexLabel;
/**
 *  信誉
 */
@property (weak, nonatomic) IBOutlet UILabel *userCredibilitylabel;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *addressLabel;
@property (weak, nonatomic) IBOutlet UILabel *detaillabel;
@property (weak, nonatomic) IBOutlet UILabel *createTimeLabel;
@property (weak, nonatomic) IBOutlet UIImageView *itemsImageView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *contentView_heigh;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *talkButton_top;

@property (weak, nonatomic) IBOutlet UIView *contentView;
@property (weak, nonatomic) IBOutlet UIButton *talkButton;
@property (weak, nonatomic) IBOutlet UIButton *acceptButton;

@end

@implementation QGHelpDetailViewController

- (void)updateViewConstraints{
    [super updateViewConstraints];
    
    [self layoutModels];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    

    self.userPictureImageView.layer.cornerRadius = 50;
    self.userPictureImageView.userInteractionEnabled = YES;
    self.userPictureImageView.clipsToBounds = YES;
    self.userPictureImageView.contentMode = UIViewContentModeScaleAspectFill;
    
}

- (void)layoutModels {
    [self.userPictureImageView sd_setImageWithURL:[NSURL URLWithString:self.helpPageModel.userico] placeholderImage:nil];
    
    self.userNameLabel.text = [NSString stringWithFormat:@"用户名：%@",self.helpPageModel.userName];
    self.userSexLabel.text = [NSString stringWithFormat:@"性别：%@",self.helpPageModel.sex];
//    信誉没写
    self.titleLabel.text = self.helpPageModel.title;
    self.addressLabel.text = [NSString stringWithFormat:@"地址：%@", self.helpPageModel.address];
    self.detaillabel.text = [NSString stringWithFormat:@"详细描述：%@", self.helpPageModel.detailInfo];
    self.createTimeLabel.text = self.helpPageModel.creatTime;
    CGFloat heigh = [self heightForView:self.helpPageModel.detailInfo font:16 width:[UIScreen mainScreen].bounds.size.width - 20];
    self.contentView_heigh.constant = heigh + 60;
    
    if (!self.helpPageModel.pictureOfSend) {
        [self.itemsImageView removeFromSuperview];
        self.talkButton_top.constant -= 200;
        
    }else {
        [self.itemsImageView sd_setImageWithURL:[NSURL URLWithString:self.helpPageModel.pictureOfSend] placeholderImage:nil];
    }
    
    
}
-(CGFloat)heightForView:(NSString *)string font:(CGFloat)fontsize width:(CGFloat)width{
    CGSize size = CGSizeMake(width, 1000);
    CGRect rect = [string boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:fontsize] } context:nil];
    return rect.size.height;
}

#pragma mark button click action
- (IBAction)headBackButton:(id)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}
- (IBAction)acceptButtonClick:(id)sender {
    
}
- (IBAction)talkButtonClick:(id)sender {
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
